<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<security:authentication property="name" var="username" />

<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
    
    <link rel="stylesheet" type="text/css" href="/css/css.css" />
  </head>
  <body>
    <div class="header">
      <div class="left">
        <div id="title">Header Title</div>
      </div>
      
      <div class="right">
        <div id="userArea" class="right">
          Logged in as: ${username}
          <br/>
          <a href="logout.html">Log out</a>
        </div>
      </div>
    </div>
    
    <div class="content-container">
      <jsp:include page="/jsp/include/menu.jsp"><jsp:param value="contactForm" name="selected"/></jsp:include>
    
      <div class="content">
        <h3>Hibernate Test 1: Contacts</h3>
        
        <form action="submitContactForm.html" method="post">
         <div class="row">
           <div class="label">First Name:</div>
           <div class="value"><input name="firstName" type="text" /></div>
         </div>
         <div class="clear"></div>
         
         <div class="row">
           <div class="label">Last Name:</div>
           <div class="value"><input name="lastName" type="text" /></div>
         </div>
         <div class="clear"></div>
         
         <div class="row">
            <div class="label">Email:</div>
            <div class="value"><input name="email" type="text" /></div>
          </div>
          <div class="clear"></div>
          
          <div class="row">
            <input class="right" type="submit" value="Store" />
         </div>
         <div class="clear"></div>
        </form>
        
        <c:if test="${not empty contactList}">
         <div class="row">
           <table>
			      <thead>
			        <tr>
			          <th>Id</th>
			          <th>First Name</th>
			          <th>Last Name</th>
			          <th>Email</th>
			          <th width="5%"></th>
			        </tr>
			      </thead>
			      <tbody>
			        <c:forEach items="${contactList}" var="contact">
			          <tr>
			            <td>${contact.id}</td>
			            <td>${contact.firstName}</td>
			            <td>${contact.lastName}</td>
			            <td>${contact.email}</td>
			            <td><a href="deleteContact.html?id=${contact.id}">Delete</a>
			          </tr>
			        </c:forEach>
			      </tbody>
			    </table>
         </div>
        </c:if>
      </div>
    </div>
    
    <jsp:include page="/jsp/include/footer.jsp" />
  </body>
</html>